home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
JCSM Shareware Collection 1997 February
/
JCSM Shareware Collection February 1997 Best of (JCS Marketing)(February 1997).bin
/
PRGTOOLS
/
TN2.ZIP
/
FACT.T
< prev
next >
Wrap
Text File
|
1996-11-15
|
610b
|
40 lines
%
% "fact.t" computes the factorial of a number
% using recursion
%
% Sample program for the T Interpreter by:
%
% Stephen R. Schmitt
% 962 Depot Road
% Boxborough, MA 01719
%
var number : int
program
prompt "Enter an integer > 0:"
get number
put ""
put "N = ", number
put "N! = ", factorial( number )
end program
function factorial( n : int ) : int
assert n <= 12 % avoid numerical overflow
if n > 0 then
n := n * factorial( n - 1 )
else
n := 1
end if
return n
end function